#!/bin/bash
passwd=$1
schoolCode=$2
pedestal=$3
# 1. 建立tomcat用户及用户组
#if [ ! id tomcat &>/dev/null]; then
#    echo "创建tomcat用户"
#    groupadd -g 1020 tomcat &>/dev/null
#    useradd -u 1020 tomcat -g tomcat &>/dev/null
#fi
#echo $passwd |passwd --stdin tomcat &>/dev/null

# 2. 检查程序目录
if [ ! -d "/opt/wiseduAppGroups" ]; then
    mkdir -p /opt/wiseduAppGroups
   # chown -R tomcat:tomcat /opt/wiseduAppGroups
fi
# 3. 初始化tomcat目录结构
mkdir -p /home/${schoolCode}/servers
cp /home/server/tomcat -R /home/$schoolCode/servers/tomcat
if [ "$pedestal" == "154" ]; then
  cp /home/server/154.war /home/$schoolCode/servers/tomcat/webapps/${schoolCode}.war
else
  cp /home/server/203.war /home/$schoolCode/servers/tomcat/webapps/${schoolCode}.war
fi
cp shell/tomcat/startServer.sh /home/$schoolCode/
cp shell/tomcat/stopServer.sh /home/$schoolCode/


#4. 设置权限
#chown -R tomcat:tomcat /home/10001_1/
chown -R weblogic:weblogic /home/$schoolCode/
chmod u+x /home/$schoolCode/ -R